var login_username = false;
var login_password = false;
//var drag = true;
var userName;
var passWord;
var left_name;
var role;

$('#login').click(function() {
    if(login_username && login_password) {
		$(function() {
			$.ajax({
				type: 'POST',
				url:"/checkLogin",
				async: true,
                ContentType: "application/x-www-form-urlencoded; charset=UTF-8",
				data: {"username":userName,"password":passWord},
		        cache: false,
		        success: function(data) {
					console.log(data);
		        	window.location.href="/home";
		        }
			});
	    });
	}
})
$('#username').blur(function() {
    userName = $('#username').val();
	$('#login-cue').text('');
	if(userName.length < 5) {
		$('#login-cue').text('用户名不得低于6位');
		login_username = false;
	} else {
		$('#login-cue').text('');
		login_username = true;
	}
	
})
$('#password').blur(function() {
	passWord = $('#password').val();
	if(passWord.length < 6) {
		$('#login-cue').text('密码不得低于6位');
		login_password = false;
	} else {
		$('#login-cue').text('');
		login_password = true;
	}
})